package ltd.dujiabao.eduoss.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author : DuJiabao
 * @Project : online-course-project
 * @Time : 2021/4/20 19:50
 * @Desc : afterPropertiesSet 方法在创建的时候就立即执行.
 * 个人理解，因为不想取对象出来，又想取值，所以用这种方式，优美的在实例化的时候将值付给静态量，直接通过类来取就好了
 */
@Component
public class ConstantPropertiesUtil implements InitializingBean {
  @Value("${aliyun.oss.file.endpoint}")
  private String endpoint;
  @Value("${aliyun.oss.file.keyid}")
  private String keyid;
  @Value("${aliyun.oss.file.keysecret}")
  private String keysecret;
  @Value("${aliyun.oss.file.bucketname}")
  private String bucketname;

  public static String ENDPOINT;
  public static String KEYID;
  public static String KEYSECRET;
  public static String BUCKETNAME;

  @Override
  public void afterPropertiesSet() throws Exception {
    ENDPOINT = endpoint;
    KEYID = keyid;
    KEYSECRET = keysecret;
    BUCKETNAME = bucketname;
  }
}
